//导入request.js请求工具
import request from '@/utils/request.js'

// 批量上传通知
export function batchAddNotifications(notifications) {
  return request({
    url: '/admins/homePageNotifications/batch',
    method: 'post',
    data: notifications
  })
}

// 获取通知列表
export function getNotificationsList() {
  return request({
    url: '/admins/homePageNotifications/list',
    method: 'get'
  })
}

// 删除通知
export function deleteNotification(nid) {
  return request({
    url: `/admins/homePageNotifications/${nid}`,
    method: 'delete'
  })
}

// 更新通知
export const updateNotification = (data) => {
  return request({
    url: '/admins/homePageNotifications/update',
    method: 'put',
    data
  })
}

// 获取轮播图列表
export function getBannersList() {
  return request({
    url: '/admins/homePageBanner/list',
    method: 'get'
  })
}


//清除图片
export function clearBanner(bid) {
  return request({
    url: `/admins/homePageBanner/clearUrl/${bid}`,
    method: 'put'
  })
}


// 上传轮播图
export function uploadBanner(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/admins/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
